package com.xjoyt.pay.master;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.EnableAsync;

@SpringBootApplication
@EnableAsync
@EnableHystrix
@EnableFeignClients(basePackages = "com.xjoyt.pay.clients")
@EnableEurekaClient
@EntityScan(basePackages = "com.xjoyt.pay.master.po")
public class PayMasterApp {

	public static ApplicationContext applicationContext;

	public static void main(String[] args) {
		applicationContext = SpringApplication.run(PayMasterApp.class, args);
	}

	public static <T> T getBean(Class<T> cls) {
		if (applicationContext == null) {
			return null;
		}
		return applicationContext.getBean(cls);
	}
}
